<template>
	<el-drawer title="反馈意见详情" v-model="visible" :size="800" destroy-on-close @closed="$emit('closed')">
		<el-container v-loading="loading">
			<el-main>
				<el-form>
					<el-form-item label="反馈姓名">
						<div style="width: 100%;" v-if="form.userName!=''&&form.userName!=null">
							<el-avatar :src="form.avatar" size="small" style="margin-top: 5px;"></el-avatar>
							<span style="position: absolute;margin-left: 15px">{{ form.userName }}</span>
							<span style="float: right">
								<div>
									<el-icon style="margin-right: 10px;"><el-icon-clock/></el-icon>{{ form.createTime }}
								</div>
							</span>
						</div>
						<div v-else>匿名</div>
					</el-form-item>
					<el-form-item label="意见标题">
						<span style="font-weight: 600;font-size: 16px">{{ form.title }}</span>
					</el-form-item>
					<el-row :gutter="24">
						<el-col :lg="12">
							<el-form-item label="意见类型">
								{{ form.mailTypeName }}
							</el-form-item>
						</el-col>
						<el-col :lg="12">
							<el-form-item label="状态">
								<el-tag type="success" v-if="form.status=='1'">已接收</el-tag>
								<el-tag type="warning" v-else>未接收</el-tag>
							</el-form-item>
						</el-col>
					</el-row>
					<el-form-item label="意见内容">
						<div v-html="form.remark"></div>
					</el-form-item>
					<el-form-item label="相关附件" v-if="form.attachId!=''">
						<attach-menu :attachIds="form.attachId" :roleFlag="3" :preview="true"></attach-menu>
					</el-form-item>
				</el-form>
				<el-footer style="text-align: center;">
					<el-button @click="visible=false">关闭</el-button>
				</el-footer>
			</el-main>
		</el-container>
	</el-drawer>
</template>

<script>
import AttachMenu from '@/views/module/attachMenu'
export default {
	emits: ['success', 'closed'],
	components: {AttachMenu},
	data() {
		return {
			loading: false,
			model:"",
			form: {
				recordId: '',
				avatar: '',
				title: '',
				userName: '',
				createTime: "",
				mailTypeName: "",
				remark: '',
			},
			visible: false,
			isSaveing: false,
		}
	},
	mounted() {

	},
	watch: {
		'model': {
			handler(val) {
				if (val) {
					this.setRecStatus();
				}
			}
		},
	},
	methods: {
		//显示
		open(model) {
			if (model == "rec") {
				this.model = "rec"
			}
			this.visible = true;
			return this;
		},
		async setRecStatus() {
			var res = await this.$API.info.LeaderMailbox.setReadLeaderMailbox.post({recordId: this.form.recordId});
			if (res.code == 200) {
				this.$emit('success')
			} else {
				this.$alert(res.message, "提示", {type: 'error'})
			}
		},
		//表单注入数据
		setData(data) {
			this.form.recordId = data.recordId
			this.form.avatar = data.avatar
			this.form.title = data.title
			this.form.userName = data.userName
			this.form.mailTypeName = data.mailTypeName
			this.form.status = data.status
			this.form.createTime = data.createTime
			this.form.remark = data.remark
			this.form.attachId = data.attachId
		},
	}
}
</script>

<style>
</style>
